package com.pangu.service;

/**
 * 服务过程中的行为异常
 * <p/>
 * Created by cxlin
 */
public class ActionException extends Exception {

    // 异常信息
    private String exMessage;

    //-----------------------------客户端本地的code值start----------------------
    //参数传递异常
    public static final int PARAM_ERROR = 1;
    //数据库操作异常
    public static final int SQL_ERROR = 2;
    //操作异常
    public static final int OPERATE_ERROR = 3;
    // 网络异常
    public static final int NETWORK_ERROR = 4;
    // 异常代号
    private int exCode = -1;
    // http 响应
    private int httpCode = -1;
    //-----------------------------客户端本地的code值end----------------------

    //-----------------------------接口返回的code值start----------------------
    //用户会话异常
    public static final int SESSION_ERROR = 40;
    //用户不存在
    public static final int USER_NOT_EXSIT = 44;
    // 已截单
    public static final int ORDER_ALREADY_CUT = 100;
    //-----------------------------接口返回的code值end----------------------

    public ActionException() {
        super();
    }

    public ActionException(int exCode) {
        super();
        this.exCode = exCode;
    }

    public ActionException(int exCode, String message) {
        super();
        this.exCode = exCode;
        this.exMessage = message;
    }

    public ActionException(int exCode, int httpCode, String message) {
        super();
        this.exCode = exCode;
        this.httpCode = httpCode;
        this.exMessage = message;
    }

    public ActionException(int exCode, String message, Throwable ex) {
        super(ex);
        this.exCode = exCode;
        this.exMessage = message;
    }

    public ActionException(int exCode, Throwable ex) {
        super(ex);
        this.exCode = exCode;
    }

    public String getExMessage() {
        return exMessage;
    }

    public void setExMessage(String exMessage) {
        this.exMessage = exMessage;
    }

    public int getExCode() {
        return exCode;
    }

    public void setExCode(int exCode) {
        this.exCode = exCode;
    }

    public int getHttpCode() {
        return httpCode;
    }

    @Override
    public String toString() {
        return "ActionException{" +
                "exCode=" + exCode +
                ", httpCode=" + httpCode +
                ", exMessage='" + exMessage + '\'' +
                '}';
    }
}
